SuperStrict
rem
	bbdoc: Type description
end rem
Import "ScintillaAbstractDriver.bmx"

Type TScintillaDefiniton Abstract
	Field _sdriver:ScintillaAbstractDriver
	Field _keys:TMap = New TMap
	
	Method RegisterKeys() Abstract
	Method Version:String() Abstract
	Method Typ:String() Abstract
	
	Method SetDriver(Driver:ScintillaAbstractDriver)
		_sdriver = Driver
	End Method
	
	Method RegisterKey(key:String, value:String = "")
		_keys.Insert(key, value)
	End Method
		
	Method Save(url:String)
		Local def:String = Typ() + "\n\r" + Version()
		def:+"{\n\r"
		For Local key:String = EachIn _keys.Keys()
			def:+key.ToUpper() + "\n\r{" + String(_keys.ValueForKey(key)) + "\n\r}"
		Next
		def:+"\n\r}"
		
		SaveText(def, url)
	End Method
	
	Method Send(MSG:Int, wp:Int, lp:Int)
		_sdriver.SendEditor(MSG, wp, lp)
	End Method
	
End Type

Const SKEY_INT:Int = 0
Const SKEY_INTARRAY:Int = 1
Const SKEY_STRING:Int = 2
Const SKEY_STRINGARRAY:Int = 3

Type TScintillaKey
	Field _key:String
	Field _type:Int
	
	Field _intvalue:Int
	Field _intarrayvalue:Int[]
	
	Field _stringvalue:String
	Field _stringarrayvalue:String[]
	
	Function CreateInt:TScintillaKey(key:String, _default:Int)
		Local sk:TScintillaKey = New TScintillaKey
		sk._key = key
		sk._type = SKEY_INT
		sk._intvalue = _default
		Return sk
	End Function
	
	Function CreateIntArray:TScintillaKey(key:String, _default:Int[])
		Local sk:TScintillaKey = New TScintillaKey
		sk._key = key
		sk._type = SKEY_INTARRAY
		sk._intarrayvalue = _default
		Return sk
	End Function
	
	Function CreateString:TScintillaKey(key:String, _default:String)
		Local sk:TScintillaKey = New TScintillaKey
		sk._key = key
		sk._type = SKEY_STRING
		sk._stringvalue = _default
		Return sk
	End Function
	
	Function CreateStringArray:TScintillaKey(key:String, _default:String[])
		Local sk:TScintillaKey = New TScintillaKey
		sk._key = key
		sk._type = SKEY_STRINGARRAY
		sk._stringarrayvalue = _default
		Return sk
	End Function
	
	Method getIntValue:Int()
		Return _intvalue
	End Method
	
	Method getIntArrayValue:Int[] ()
		Return _intarrayvalue
	End Method
	
	Method getStringValue:String()
		Return _stringvalue
	End Method
	
	Method getStringArrayValue:String[] ()
		Return _stringarrayvalue
	End Method
	
	Method toString:String()
		Select _type
			Case SKEY_INT
				Return "[INT]\n\r" + String(_intvalue)
			Case SKEY_STRING
				Return "[STRING]\n\r" + String(_stringvalue)
			Case SKEY_INTARRAY
				Local r:String = "[INTARRAY]\n\r"
				For Local I:Int = 0 To _intarrayvalue.Length - 1
					r:+String(_intarrayvalue[I]) + "\n\r"
				Next
			Case SKEY_STRINGARRAY
				Local r:String = "[STRINGARRAY]\n\r"
				For Local I:Int = 0 To _stringarrayvalue.Length - 1
					r:+String(_stringarrayvalue[I]) + "\n\r"
				Next
		End Select
	End Method
	
End Type
